package com.neusoft.resturant.service.impl;


import com.neusoft.resturant.entity.ResCart;
import com.neusoft.resturant.mapper.ResCartMapper;
import com.neusoft.resturant.service.IResCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 购物车Service业务层处理
 * 
 * @author sl
 * @date 2023-12-20
 */
@Service
public class ResCartServiceImpl implements IResCartService
{
    @Autowired
    private ResCartMapper resCartMapper;

    /**
     * 查询购物车
     * 
     * @param id 购物车主键
     * @return 购物车
     */
    @Override
    public ResCart selectResCartById(Long id)
    {
        return resCartMapper.selectResCartById(id);
    }

    /**
     * 查询购物车列表
     * 
     * @param resCart 购物车
     * @return 购物车
     */
    @Override
    public List<ResCart> selectResCartList(ResCart resCart)
    {
        return resCartMapper.selectResCartList(resCart);
    }

    /**
     * 新增购物车
     * 
     * @param resCart 购物车
     * @return 结果
     */
    @Override
    public int insertResCart(ResCart resCart)
    {
        resCart.setCreateTime(new Date());
        return resCartMapper.insertResCart(resCart);
    }

    /**
     * 修改购物车
     * 
     * @param resCart 购物车
     * @return 结果
     */
    @Override
    public int updateResCart(ResCart resCart)
    {
        resCart.setUpdateTime(new Date());
        return resCartMapper.updateResCart(resCart);
    }

    /**
     * 批量删除购物车
     * 
     * @param ids 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteResCartByIds(Long[] ids)
    {
        return resCartMapper.deleteResCartByIds(ids);
    }

    /**
     * 删除购物车信息
     * 
     * @param id 购物车主键
     * @return 结果
     */
    @Override
    public int deleteResCartById(Long id)
    {
        return resCartMapper.deleteResCartById(id);
    }
}
